package com.lyq.mr.speak;

import lombok.Data;
import lombok.NonNull;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data

public class SpeakBean implements Writable {
    @Override
    public void write(DataOutput out) throws IOException {
            out.writeLong(selfDuration);
            out.writeLong(thirdPartDuration);
            out.writeUTF(deviceId);
            out.writeLong(sumDuration);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.selfDuration=in.readLong();
        this.thirdPartDuration=in.readLong();
        this.deviceId=in.readUTF();
        this.sumDuration=in.readLong();

    }


    //准备一个空参构造

    public SpeakBean() {
    }

    //有参构造

    public SpeakBean(Long selfDuration, Long thirdPartDuration, String deviceId) {
        this.selfDuration = selfDuration;
        this.thirdPartDuration = thirdPartDuration;
        this.deviceId = deviceId;
        this.sumDuration = this.selfDuration + this.thirdPartDuration;
    }
    //定义属性
    private Long selfDuration;//自有内容时长
    private Long thirdPartDuration;//第三方内容时长
    private String deviceId;//设备id
    private Long sumDuration;//总时长




}
